package com.wgy.day21.Calendar类;

import java.util.Calendar;

/**
 * Created by pc on 2020/11/19 22:11
 * Description: LearningJava
 */
public class Demo03Calendar {
    public static void main(String[] args) {
        //使用getInstance()方法获得 Calendar对象a --->使用默认时区和语言环境获得一个当前时间日历
        Calendar a = Calendar.getInstance();
        int d = a.get(Calendar.YEAR);
        int b = a.get(Calendar.MONTH);
        int c = a.get(Calendar.DATE);
        System.out.println(d);        //2020
        System.out.println(b);        //10
        System.out.println(c);        //19

        a.add(Calendar.YEAR, 5);
        a.add(Calendar.MONTH, -4);
        a.add(Calendar.DATE, -6);
        int year = a.get(Calendar.YEAR);
        int month = a.get(Calendar.MONTH);
        int date= a.get(Calendar.DATE);
        System.out.println(year);        //2025
        System.out.println(month);       //6
        System.out.println(date);       //13

    }
}
